File Handler Documentation


About

"File Handler" is a set of php file routines that simplify opening, creating, editing and deleting files. File Handler eliminates the need to add many lines of code to your php program just perform simple file tasks. File Handler is absolutely free.

How to read a file on the server in PHP

This is very easy and we can do it in just two lines:

include('gsg_fh_functions.php');
$theText = ReadFromFile('the_local_file.txt');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here


How to read a Url in PHP

In just two lines:

include('gsg_fh_functions.php');
$theText = ReadFromUrl('http://www.example.com');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here


How to create a new file in PHP

All you do is:

include('gsg_fh_functions.php');
CreateFile('the_new_file.txt', 'This is default text.');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here
You can also use "WriteToFile" instead of "CreateFile".

How to delete a file in PHP

This is very easy and we can do it in just two lines:

include('gsg_fh_functions.php');
DeleteFile('the_local_file.txt');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here


How to empty or truncate a file in PHP

Emptying a file will take a text file, for example, full of text and leave it empty without text.
Simply do this:

include('gsg_fh_functions.php');
EmptyFile('the_local_file.txt');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here
You can also use "TruncateFile" instead of "EmptyFile".

How to add text to a file in PHP

To add text to the end of a text, html or any file you can use the following code:

include('gsg_fh_functions.php');
AddToFile('the_local_file.txt', 'This is the text to add.');

The included file "gsg_fh_functions.php" can be found in the 'File Handler' download Here
You can also use "AppendFile" instead of "AddToFile".